// OP_ODBC.cpp : Defines the entry point for the DLL application.
//
#include <stdlib.h>
#include <windows.h>
#include <odbcinst.h>

#ifdef _MANAGED
#pragma managed(push, off)
#endif

/*
DLL initializer for WIN32.
@param hinst instance handle
@param reason reason code for entry point
@param reserved
@result always true
*/
#if defined(WIN32) 
HINSTANCE NEAR s_hModule;
/*This is where the DM attaches to this Driver*/
BOOL WINAPI DllMain(HMODULE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
	switch (ul_reason_for_call) {
	case DLL_PROCESS_ATTACH:
		break;
	case DLL_THREAD_ATTACH:
		break;
	case DLL_PROCESS_DETACH:
		return TRUE;
	case DLL_THREAD_DETACH:
		break;
	default:
		break;
	}
	return 1;/*LibMain(hinst, reason, reserved);*/
}

#endif

BOOL INSTAPI ConfigDSN(HWND hWnd, WORD nRequest, LPCSTR pszDriver, LPCSTR pszAttributes)
{
#if 0
	OPODBCUTIL_DATASOURCE *pDataSource = OPODBCUtil_AllocDataSource(OPODBCUTIL_DATASOURCE_MODE_DSN_VIEW);
	BOOL bReturn = FALSE;

	if (!OPODBCUtil_ReadDataSourceStr(pDataSource, OPODBCUTIL_DELIM_BOTH, pszAttributes))
	{
		SQLPostInstallerError(ODBC_ERROR_INVALID_KEYWORD_VALUE, "Data Source string seems invalid.");
		goto exitConfigDSN;
	}

	if(pDataSource->pszDRIVER) {
		SQLPostInstallerError(ODBC_ERROR_INVALID_KEYWORD_VALUE, "DRIVRE is an invalid attribute.");
		goto exitConfigDSN;
	}

	if(!pszDriver || !(*pszDriver)) {
		SQLPostInstallerError(ODBC_ERROR_INVALID_KEYWORD_VALUE, "Need driver name.");
		goto exitConfigDSN;
	}

	pDataSource->pszDRIVER = (char *)_global_strdup(pszDriver);

	switch(nRequest) {
		case ODBC_ADD_DSN:
			bReturn = OPODBCSetupConfigDSNAdd(hWnd, pDataSource);
			break;
		case ODBC_CONFIG_DSN:
			bReturn = OPODBCSetupConfigDSNEdit(hWnd, pDataSource);
			break;
		case ODBC_REMOVE_DSN:
			bReturn = OPODBCSetupConfigDSNRemove(pDataSource);
			break;
		default:
			SQLPostInstallerError(ODBC_ERROR_INVALID_REQUEST_TYPE, "Invalid request.");
	}

exitConfigDSN:
	OPODBCUtil_FreeDataSource(pDataSource);
#endif
	return FALSE;
}

#ifdef _MANAGED
#pragma managed(pop)
#endif
